//
//  UIColor+Extension.swift
//  SHWeibo2.0
//
//  Created by 黄礼潮 on 16/2/27.
//  Copyright © 2016年 黄礼潮. All rights reserved.
//

import UIKit

extension UIColor{


   class func cz_colorWithHex(hex: UInt32) -> UIColor{
    
    //0x0000FF 0000 0000 0000 0000 1111 1111
    
        let r = (hex & 0xFF0000) >> 16  //二进制运算
        
        let g = (hex & 0x00FF00) >> 8
        
        let b = (hex & 0x0000FF)
        
        return cz_color(r ,g: g, b: b)
       
    }
    
    class func cz_color(r: UInt32, g: UInt32, b: UInt32) -> UIColor{
    
     
       return UIColor(red: CGFloat(r) / 255.0, green: CGFloat(g) / 255.0, blue: CGFloat(b) / 255.0, alpha: 1.0)
    }
    
    class func cz_radomColor() -> UIColor{
    
      return cz_color(UInt32(random() % 256), g: UInt32(random() % 256), b: UInt32(random() % 256))
    }

}
